#!bin/bash

if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 day' +%F`
fi

AUTO_HOME_SEARCH_LOG_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/car_home_warehouse/auto_home_search_log/${data_date}'
    OVERWRITE INTO TABLE car_home_warehouse.auto_home_search_log PARTITION (dt='${data_date}')
;
"

CAR_BRAND_INFORMATION_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/car_home_warehouse/car_brand_information/${data_date}'
    OVERWRITE INTO TABLE car_home_warehouse.car_brand_information PARTITION (dt='${data_date}')
;
"

CAR_SERIES_INFORMATION_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/car_home_warehouse/car_series_information/${data_date}'
    OVERWRITE INTO TABLE car_home_warehouse.car_series_information PARTITION (dt='${data_date}')
;
"

MODEL_INFORMATION_SHEET_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/car_home_warehouse/model_information_sheet/${data_date}'
    OVERWRITE INTO TABLE car_home_warehouse.model_information_sheet PARTITION (dt='${data_date}')
;
"

KEYWORD_MAPPING_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/car_home_warehouse/keyword_mapping/${data_date}'
    OVERWRITE INTO TABLE car_home_warehouse.keyword_mapping PARTITION (dt='${data_date}')
;
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -p 123456 -e "${AUTO_HOME_SEARCH_LOG_SQL}${CAR_BRAND_INFORMATION_SQL}${CAR_SERIES_INFORMATION_SQL}${MODEL_INFORMATION_SHEET_SQL}${KEYWORD_MAPPING_SQL}"



